package thread;

public class Thread5{
    private String username="a";
    private String password="aa";

    public String getUsername() {
        return username;
    }

    public void setUsername(String username) {
        this.username = username;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    synchronized public void printString(String username,String password){
        try {
            this.username=username;
            Thread.sleep(100000);
            this.password=password;
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }

    public static void main(String[] args) {
        try {
            Thread5 thread5=new Thread5();
            MyThread5 myThread5=new MyThread5(thread5);
            myThread5.start();
            Thread.sleep(500);
            myThread5.stop();
            System.out.println(thread5.getUsername()+" "+thread5.getPassword());
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }

}

class MyThread5 extends Thread{
    private Thread5 thread5;
    public MyThread5(Thread5 thread5){
        this.thread5=thread5;
    }
    @Override
    public void run() {
       thread5.printString("b","bb");
    }
}

